package cn.wzl.recognition.mvc;

import java.awt.BorderLayout;
import java.awt.GridLayout;

import javax.swing.*;

public class View extends JFrame {

    private final JPanel picPanel;
    private final JButton clearButton;
    private final JButton runButton;
    private final JButton trainingButton;
    private final JButton trainThisPicButton;

    private final JTextField trainingTimes;
    private final JTextField expectedValue;

    public final int PEN_WIDTH = 15;

    public View(String title, int width, int height) {

        picPanel = new JPanel();
        JPanel background = new JPanel();
        background.setLayout(new GridLayout(6, 1, 0, 10));
        runButton = new JButton("run");
        clearButton = new JButton("clear");
        trainingButton = new JButton("training");
        trainingTimes = new JTextField("1");
        trainThisPicButton = new JButton("training this!");
        expectedValue = new JTextField();

        background.add(runButton);
        background.add(clearButton);
        background.add(trainingButton);
        background.add(trainingTimes);
        background.add(trainThisPicButton);
        background.add(expectedValue);

        getContentPane().add(background, BorderLayout.EAST);
        getContentPane().add(picPanel, BorderLayout.CENTER);

        //this.setUndecorated(true); 去除windows窗体样式
        this.setTitle(title);
        this.setSize(width, height);
        this.setLocationRelativeTo(null);
        this.setResizable(false);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setVisible(true);
    }

    public JButton getClearButton(){
        return clearButton;
    }
    public JButton getRunButton(){
        return runButton;
    }
    public JButton getTrainingButton() {
        return trainingButton;
    }
    public JTextField getTrainingTimes() {
        return trainingTimes;
    }

    public JButton getTrainThisPicButton() {
        return trainThisPicButton;
    }
    public JTextField getExpectedValue() {
        return expectedValue;
    }
    public JPanel getPicPanel() {
        return picPanel;
    }
}